﻿using Comkarl.Web.Resources;
using Comkarl.Web.UI.Controls;
using System.Web;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;

namespace Comkarl.Calipso.Web.SampleClient.Controls
{
    public sealed class LocalizedHelloWorldAndAlert : ScriptControl
    {
        protected override string CommonID
        {
            get
            {
                return "LocalizedHelloWorldAndAlert";
            }
        }

        protected override string ControlElementCssClass
        {
            get
            {
                return "localized-helloworld-and-alert";
            }
        }

        protected override void CreateChildControls()
        {
            HtmlGenericControl text = new HtmlGenericControl("span");
            text.Attributes["class"] = ControlElementCssClass;
            text.Controls.Add(new Literal { Text = GetResourceString("ServerText") });
            Controls.Add(text);
        }

        protected override void OnLoad(System.EventArgs e)
        {
            base.OnLoad(e);

            JavaScriptManager.RegisterInclude
            (
                "Controls//LocalizedHelloWorldAndAlert",
                "Comkarl.Calipso.Web.SampleClient.Controls.LocalizedHelloWorldAndAlert.ScriptControl.js, Comkarl.Calipso.Web.SampleClient", 
                ResourceKind.Resource
            );

            JavaScriptManager.RegisterReference("Controls//LocalizedHelloWorldAndAlert");
        }
    }
}